<?php
namespace app\store\controller;

use think\Controller;

class Login extends Controller
{
    public function login()
    {
        if ($_POST) {
            $result = DB("admin")->where(['login_name' => $_POST['username'],"pwd" => md5($_POST['password'])])->find();
            
            if (!empty($result)) {
                session("admin", $result);
                $this->success();
            } else {
                $this->error("用户名或密码不正确");
            }
            echo json_decode($data);
        } else {
            return $this->fetch('');
        }
    }


    public function logout()
    {
        session("admin", "");
        $this->redirect("/index.php/index/login/login");
    }
}
